class Solution {
public:
    int dayOfYear(string date) {
      int year = stoi(date.substr(0,4));
      int month = stoi(date.substr(5,2));
      int day = stoi(date.substr(8,2));

      int amount[]={0,31,28,31,30,31,30,31,31,30,31,30};
      if(year%4==0&&year%100!=0||year%400==0){
        amount[2]++;
      }
      for(int i=0;i<month;i++){
        day += amount[i];
      }
      return day;
    }
};
